import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/editor',
    name: 'Home',
    meta:{
      title:'编辑器',
    },
    component: Home
  },
  {
    path: '/view',
    name: 'view',
    component: ()=>import('../views/view-content.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

router.beforeEach((to,from,next)=>{
  if(to.meta.title){
    document.title = to.meta.title
  }
  next()
})

export default router
